﻿@{
    ViewBag.Title = "Index";
}
<form method="post" >
@Html.AntiForgeryToken()
<div class="querybar">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                标题：<input type="text" class="mytext" id="Title" name="Title" value="" />
                分类：<select class="myselect" id="Type" name="Type"><option value="">==全部==</option>@Html.Raw(ViewBag.TypeOptions)</select>
                人员：<input type="text" user="true" dept="false" value="" station="false" unit="false" more="false" group="false" id="UserID" name="UserID" class="mymember" />
                发生日期：<input type="text" class="mycalendar" id="Date1" name="Date1" style="width:90px;" value="" /> 至 <input type="text" class="mycalendar" id="Date2" name="Date2" style="width:90px;" value="" />
                <input type="button" name="Search" onclick="query(null, 1);" value="&nbsp;&nbsp;查&nbsp;询&nbsp;&nbsp;" class="mybutton" />
            </td>
        </tr>
    </table>
</div>
<table id="listtable"></table>
<div class="buttondiv"></div>
</form>
<script type="text/javascript">
    var appid = '@Request.QueryString["appid"]';
    var iframeid = '@Request.QueryString["tabid"]';
    var dialog = top.mainDialog;

    $(function ()
    {
        $("#listtable").jqGrid({
            url: RoadUI.Core.rooturl() + "/Log/Query",
            postData: { "__RequestVerificationToken": $("input[name='__RequestVerificationToken']").val(), "appid": appid },
            mtype: 'POST',
            datatype: "json",
            colNames: ['标题', '分类', '发生时间', '操作员', '发生IP', '详细'],
            colModel: [
                { name: 'Title', index: 'Title' },
                { name: 'Type', index: 'Type', align: "left" },
                { name: 'WriteTime', index: 'WriteTime', align: "left" },
                { name: 'UserName', index: 'UserName', align: "left", width: 50 },
                { name: 'IPAddress', index: 'IPAddress', align: "left", width: 80 },
                { name: 'Opation', index: '', sortable: false, align: "left", width: 50 }
            ],
            sortname: "WriteTime",
            sortorder: "desc",
            height: '100%',
            width: $(window).width(),
            loadComplete: function ()
            {
                var gridObj = $("#listtable");
                var records = gridObj.getGridParam("userData");
                $(".buttondiv").html(RoadUI.Core.getPager1(records.total, records.pagesize, records.pagenumber, "query"));
            }
        });
    });
    function query(size, number)
    {
        var data = {
            __RequestVerificationToken: $("input[name='__RequestVerificationToken']").val(),
            Title: $("#Title").val(), Type: $("#Type").val(), appid: appid,
            UserID: $("#UserID").val(), Date1: $("#Date1").val(), Date2: $("#Date2").val(),
            pagesize: size, pagenumber: number
        };
        $("#listtable").setGridParam({ postData: data }).trigger("reloadGrid");
    }
    function detail(id)
    {
        dialog.open({ id: "window_" + appid.replaceAll('-', ''), title: "查看日志详细信息", width: 980, height: 550, url: "/Log/Detail?id=" + id + '@Html.Raw(ViewBag.Query)', opener:window, openerid: iframeid });
    }
</script>